home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / batch / tsbat36.zip / ADDPATH.BAT next >
DOS Batch File  |  1990-10-21  |  2KB  |  63 lines

  1. echo off
  2. echo.
  3. echo ┌───────────────────────────────────────────────────┐
  4. echo │ Add new directories to the path                   │
  5. echo │ By Prof. Timo Salmi, ts@chyde.uwasa.fi, 21-Oct-90 │
  6. echo └───────────────────────────────────────────────────┘
  7. echo.
  8.  
  9. if "%1"=="" goto _help
  10.  
  11. rem Set the new path, loop and shift to allow adding more than one directory
  12. :_loop
  13. if "%1"=="" goto _out
  14. rem Check that the directory exists
  15. if not exist %1\nul if not exist %1nul goto _err1
  16. set tmp_=%path%
  17. rem Check that not already at path, first make uppercase
  18. path=%1
  19. set upcase_=%path%
  20. path=%tmp_%
  21. set double_=false
  22. for %%f in (%path%) do if "%upcase_%"=="%%f" set double_=true
  23. for %%f in (%path%) do if "%upcase_%"=="%%f\" set double_=true
  24. for %%f in (%path%) do if "%upcase_%\"=="%%f" set double_=true
  25. if "%double_%"=="true" goto _err2
  26. rem Add the directory to the path
  27. path=%tmp_%;%1
  28. shift
  29. goto _loop
  30.  
  31. :_help
  32. echo Usage: ADDPATH [FirstNewDirectory] [SecondNewDirectory] [...]
  33. echo.
  34. echo Examples: ADDPATH c:\bat
  35. echo           ADDPATH c:\telec\kermi e:\arczip
  36. echo.
  37. echo The original path can be saved and restored by applying
  38. echo pushpath.bat and poppath.bat. This is useful if you want your
  39. echo addition to be temporary only.
  40. echo.
  41. echo If you get an "Out of environment space" message, increase your
  42. echo environment space by using shell configuration in config.sys:
  43. echo MsDos 3.30 example: shell=c:\bin\command.com /e:1024 /p
  44. echo.
  45. echo Current path %path%
  46. goto _out2
  47.  
  48. :_err1
  49. echo Directory %1 does not exist, not added
  50. goto _out
  51.  
  52. :_err2
  53. echo Directory %1 already at path, not added
  54. goto _out
  55.  
  56. :_out
  57. path
  58. :_out2
  59. set tmp_=
  60. set double_=
  61. set upcase_=
  62. echo on
  63.